package com.pimwi.dp
{
  import com.pimwi.vo.User;

  import flash.events.Event;
  import flash.events.EventDispatcher;

  public class UserDP extends EventDispatcher
  {
    private var _user:User;

    public function UserDP(user:User = null)
    {
      _user = user;
      dispatchEvent(new Event("userChanged"));
    }

    [Bindable("userChanged")]
    public function get user():User
    {
      return _user;
    }
    public function set user(user:User):void
    {
      _user = user;
      dispatchEvent(new Event("userChanged"));
    }

    [Bindable("userChanged")]
    [Bindable("idChanged")]
    public function get id():int
    {
      return _user.id;
    }
    public function set id(id:int):void
    {
      _user.id = id;
      dispatchEvent(new Event("idChanged"));
    }

    [Bindable("userChanged")]
    [Bindable("firstNameChanged")]
    public function get firstName():String
    {
      return _user.firstName;
    }
    public function set firstName(firstName:String):void
    {
      _user.firstName = firstName;
      dispatchEvent(new Event("firstNameChanged"));
    }

    [Bindable("userChanged")]
    [Bindable("lastNameChanged")]
    public function get lastName():String
    {
      return _user.lastName;
    }
    public function set lastName(lastName:String):void
    {
      _user.lastName = lastName;
      dispatchEvent(new Event("lastNameChanged"));
    }

    [Bindable("userChanged")]
    [Bindable("userNameChanged")]
    public function get userName():String
    {
      return _user.userName;
    }
    public function set userName(userName:String):void
    {
      _user.userName = userName;
      dispatchEvent(new Event("userNameChanged"));
    }

    [Bindable("userChanged")]
    [Bindable("passwordChanged")]
    public function get password():String
    {
      return _user.password;
    }
    public function set password(password:String):void
    {
      _user.password = password;
      dispatchEvent(new Event("passwordChanged"));
    }

    [Bindable("userChanged")]
    [Bindable("firstNameChanged")]
    [Bindable("lastNameChanged")]
    public function get completeName():String
    {
      return _user.firstName + " " + _user.lastName;
    }

  }
}